package org.practice.interceptor;


import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class ExceptionInterceptor implements Interceptor{

	@Override
	public void destroy() {
		
	}

	@Override
	public void init() {
		
	}

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		ActionSupport baseAction = (ActionSupport)invocation.getAction();
		
	    long actionTime = 0L;
	   
	    try{
	    	actionTime = System.currentTimeMillis();
	    	String result = invocation.invoke();
	    	actionTime = System.currentTimeMillis() - actionTime;
	    	System.out.println("action执行时间 = " + actionTime + "毫秒");
	    	return result;
	    } catch (Exception e) {
	    	return "exception";
	    }
	}
 
}